home *** CD-ROM | disk | FTP | other *** search
- Path: news.missouri.edu!news
- From: pixel@rhino.coe.missouri.edu (James P. Cooper)
- Newsgroups: comp.lang.c
- Subject: Reading stdin twice
- Date: 3 Apr 1996 02:42:53 GMT
- Organization: University of Missouri - Columbia
- Message-ID: <4jsojd$1hlk@news.missouri.edu>
- Reply-To: pixel@coe.missouri.edu
- NNTP-Posting-Host: rhino.coe.missouri.edu
- X-Newsreader: knews 0.9.5
-
-
- Hi,
-
- I'm writing a program, and I'd like two functions to read the stdin
- stream. Is this possible? I realize I could pass a pointer to the
- buffer after the first function fread's stdin, but this would break
- something else more serious.
-
- Example of what I'm doing:
-
- void read_first() {
- char *input;
- FILE *infile;
-
- length = 5000;
- fread(input, sizeof(char), length, stdin);
-
- /* Do stuff with data here... */
- }
-
- void read_again() {
- char *input;
- FILE *infile;
-
- length=5000;
- fread(input,sizeof(char),length,stdin);
-
- /* Do something different */
- }
-
- I've tried to use fwrite to rewrite the buffer back to stdin, but that
- didn't work (presumably because stdin is read-only).
-
- Any ideas?
-
- Thanks
-
- -- James
-
- --
- .........................................................................
- James Paul Cooper * Pixel
- MU College of Education
- pixel@coe.missouri.edu - http://tiger.coe.missouri.edu/~pixel/
- .........................................................................
-
-